<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改婚庆公司')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content" >
		<form class="form-horizontal m" id="form-host-edit" th:object="${company}">
			<input id="postId" name="postId" type="hidden" th:field="*{companyId}"/>
			<div class="form-group">
				<label class="col-sm-3 control-label">公司名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="companyName" id="companyName" required th:field="*{companyName}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label ">法人姓名：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="companyBoss" id="companyBoss" required th:field="*{companyBoss}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">手机号：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="companyPhone" id="companyPhone" required th:field="*{companyPhone}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">邮箱：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="companyEmail" id="companyEmail" required th:field="*{companyEmail}">
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "user/company";



		$("#form-host-edit").validate({
			onkeyup: false,
			rules:{
				companyName:{
					remote: {
						url: prefix +"/checkName",
						type: "post",
						dataType: "json",
						data: {
							"companyName" : function() {
								return $.common.trim($("#companyName").val());
							}
						},
						dataFilter: function(data, type) {
							return $.validate.unique(data);
						}
					}
				},
				companyEmail:{
					remote: {
						url: prefix +"/checkEmail",
						type: "post",
						dataType: "json",
						data: {
							"companyEmail" : function() {
								return $.common.trim($("#companyEmail").val());
							}
						},
						dataFilter: function(data, type) {
							return $.validate.unique(data);
						}
					}
				},
				companyPhone:{
					remote: {
						url: prefix +"/checkPhone",
						type: "post",
						dataType: "json",
						data: {
							"companyPhone" : function() {
								return $.common.trim($("#companyPhone").val());
							}
						},
						dataFilter: function(data, type) {
							return $.validate.unique(data);
						}
					}
				},
				postSort:{
					digits:true
				},
			},
			messages: {
				"companyName": {
					remote: "公司已被注册"
				},
				"companyEmail": {
					remote: "请更换一个邮箱"
				},
				"companyPhone": {
					remote: "请更换手机号"
				}
			},
			focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/edit", $('#form-host-edit').serialize());
	        }
	    }
	</script>
</body>
</html>
